package com.linshengjian.snowball.finance.entity;

import com.linshengjian.snowball.core.BaseEntity;
import com.linshengjian.snowball.finance.UseType;
import com.linshengjian.snowball.finance.model.Savings;
import com.linshengjian.snowball.finance.model.SavingsRecord;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import javax.persistence.*;

@Accessors(chain = true)
@Getter
@Setter
@Entity(name = "savings_record")
public class SavingsRecordEntity extends BaseEntity<Long, SavingsRecord> {
    @Column(nullable = false, unique = true)
    private String oddNum; // 单号
    @Column(nullable = false)
    @Enumerated(EnumType.STRING)
    private UseType type; // 类型，收入/支出
    @Column(nullable = false, columnDefinition = "double default 0")
    private Double amount; // 金额
    @Column(nullable = false, columnDefinition = "double default 0")
    private Double balance;// 账户剩余金额
    private String remark; // 备注

    @ManyToOne
    @JoinColumn(nullable = false)
    private SavingsEntity savings;
}
